# This file is part of Neuroinfo Toolkit.
#
# Neuroinfo Toolkit is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Neuroinfo Toolkit is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Neuroinfo Toolkit.  If not, see <http://www.gnu.org/licenses/>.

import unittest
from neuro.system import *

class TestSystem(unittest.TestCase):
	def setUp(self):
		pass

	def test_hostname(self):
		self.assertNotEqual(getHostname(), "")

	def test_getOS(self):
		self.assertNotEqual(getOS(), "")

	def test_email(self):
		pass

	def test_getUsername(self):
		self.assertNotEqual(getUsername(), "")

	def test_getUID(self):
		self.assertNotEqual(getUID(), "")

	def test_getLoad(self):
		self.assertRaises(IllegalArgumentException, getLoad, "foo")
		self.assertNotEqual(getLoad(), "")
		self.assertNotEqual(getLoad(5), "")
		self.assertNotEqual(getLoad(15), "")

	def test_getYear(self):
		self.assertNotEqual(getYear(), "")

	def test_getMonth(self):
		self.assertNotEqual(getMonth(), "")

	def test_getDay(self):
		self.assertNotEqual(getDay(), "")

	def test_getHour(self):
		self.assertNotEqual(getHour(), "")

	def test_getMinute(self):
		self.assertNotEqual(getMinute(), "")

	def test_getSecond(self):
		self.assertNotEqual(getSecond(), "")

	def test_getEnvironmentVariable(self):
		self.basic(getEnvironmentVariable)
		self.assertNotEqual(getEnvironmentVariable("HOME"), "")

	def test_setEnvironmentVariable(self):
		self.basic(getEnvironmentVariable)
		self.assertNotEqual(setEnvironmentVariable("ABCDEFG1234", "foo"), "foo")
		self.assertEqual(getEnvironmentVariable("ABCDEFG1234"), "foo")
		unsetEnvironmentVariable("ABCDEFG1234")

	def unsetEnvironmentVariable(self):
		setEnvironmentVariable("ABCDEFG1234", "foo")
		self.assertEqual(unsetEnvironmentVariable("ABCDEFG1234"), None)

	def check(self):
		pass

	def basic(self, method):
		## --- no arguments
		self.assertRaises(TypeError, method)

		## --- bad argument
		self.assertRaises(IllegalArgumentException, method, list())
		self.assertRaises(IllegalArgumentException, method, "")

unittest.main()